<template>
    <el-card style="width: 480px;margin:100px auto">
        <span style="color:red">{{msg}}</span>
        <el-form v-model="form">
            <el-form-item label="账号">
                <el-input v-model="form.username" placeholder="请输入账号"></el-input>
            </el-form-item>
            <el-form-item label="密码">
                <el-input type="password" v-model="form.password" placeholder="请输入密码"></el-input>
            </el-form-item>
            <el-button @click="login">登录</el-button>
        </el-form>
    </el-card>
</template>

<script>
    export default {
        name: "Login",
        data(){
            return{
                msg:"",
                form:{username:"",password:""}
            }
        },
        methods:{
            login(){
                this.$http.post("http://api.blb.com/api/auth-api/user/login",this.$qs.stringify(this.form))
                    .then(res => {
                        if(res.data.code == 1){
                            this.$message.info("登录成功");
                            this.$router.push("/index");
                        }else{
                            this.msg = "账号或密码错误";
                        }
                    });
            }
        }
    }
</script>

<style scoped>

</style>